
<div class="gird_24 dpage">
    <div class="dcontent" style="padding: 28px 0">
            <div class="dbr5" style="
                        min-height: 400px;
                    background: rgb(247,247,247);
            -webkit-box-shadow:  0px 0px 6px #000;
                -moz-box-shadow:  0px 0px 6px #000;
                            box-shadow:  0px 0px 6px #000;
                            ">
                    <div style="padding:20px 0 0px 20px">
                        
                            <div class="dmenutwo">
                                <div style="float: left">
                                    <a href="{{base_url()}}{{$Configs["dealtype"]}}"><div class="item {{if $Configs["Category"]==""}}active{{/if}}">Tất cả</div></a>
                                    {{foreach $data["categorys"] as $ca}}
                                    <a href="{{base_url()}}{{$Configs["dealtype"]}}/{{$ca["alias"]}}">
                                        <div class="item {{if $ca["alias"]==$Configs["Category"]}}active{{/if}}">
                                            {{$ca["name"]}}
                                        </div>
                                    </a>
                                    {{/foreach}}
                                </div>
                            </div>
                            
                            <div class="dgroup dbig" style="margin-top: 20px">
                                    {{if isset($data["products"][0])}}
                                    <div class="ditem dl">
                                            <div class="dphoto">
                                                    <img src="{{$data["products"][0]["Image"]}}" class=""/>
                                                    {{if $data["products"][0]["Discontinued"]==1}}<div class="sold-out"></div>{{/if}}
                                                    <a href="{{base_url()}}sanpham/{{$data["products"][0]["Alias"]}}">
                                                        <div class="ho50">
                                                            <div class="dship">
                                                                Giao sản phẩm
                                                            </div>
                                                            <div class="dview"></div>
                                                        </div>
                                                    </a>
                                                    <div class="ddisc">-{{$data["products"][0]["Discount"]}}%</div>
                                                    
                                            </div>
                                            <div class="dtit">
                                                <a href="{{base_url()}}sanpham/{{$data["products"][0]["Alias"]}}">
                                                    <h1>
                                                            {{$data["products"][0]["ProductName"]}}
                                                    </h1>
                                                </a>
                                            </div>
                                            <div class="dprice">
                                                    <div class="dsale">
                                                            <div>
                                                            {{number_format($data["products"][0]["UnitsOnOrder"], 0, ',', '.')}}<sup style="font-size:20px;">đ</sup>
                                                            </div>
                                                    </div>
                                                    <div class="dunitprice">
                                                            <span class="sf">Trị giá</span><br/>
                                                            <span class="ss">{{number_format($data["products"][0]["UnitPrice"], 0, ',', '.')}}<sup style="font-size:12px;">đ</sup></span>
                                                    </div>
                                            </div>
                                            <div class="df_time_view">
                                                    <div class="dtime">
                                                        <b>{{round((strtotime($data["products"][0]["EndDate"])-strtotime("now"))/(60*60*24))}}</b> ngày 
                                                        <b>{{round( ((strtotime($data["products"][0]["EndDate"])-strtotime("now"))%(60*60*24))/(60*60) )}}</b> giờ 
                                                        <b>{{round( (((strtotime($data["products"][0]["EndDate"])-strtotime("now"))%(60*60*24))%(60*60))/60 )}}</b> phút
                                                        
                                                    </div>
                                                    <div class="hidden" style="position:absolute;top:0px;right :20px;padding-right:0px;line-height:40px;font-size:14px;text-align:center">
                                                             <b>{{$data["products"][0]["Sold"]+$data["products"][0]["ReorderLevel"]}}</b> người đã mua
                                                    </div>
                                            </div>
                                    </div>
                                    {{else}}
                                    Mục này không có sản phẩm nào
                                    {{/if}}
                                    {{if isset($data["products"][1])}}
                                    <div class="ditem dr">
                                            <div class="dphoto">
                                                    <img src="{{$data["products"][1]["Image"]}}" class=""/>
                                                    {{if $data["products"][1]["Discontinued"]==1}}<div class="sold-out"></div>{{/if}}
                                                    <a href="{{base_url()}}sanpham/{{$data["products"][1]["Alias"]}}">
                                                        <div class="ho50">
                                                            <div class="dship">
                                                                Giao sản phẩm
                                                            </div>
                                                            <div class="dview"></div>
                                                        </div>
                                                    </a>
                                                    <div class="ddisc">-{{$data["products"][1]["Discount"]}}%</div>
                                                    
                                            </div>
                                            <div class="dtit">
                                                <a href="{{base_url()}}sanpham/{{$data["products"][1]["Alias"]}}">
                                                    <h1>
                                                            {{$data["products"][1]["ProductName"]}}
                                                    </h1>
                                                </a>
                                            </div>
                                            <div class="dprice">
                                                    <div class="dsale">
                                                            <div>
                                                            {{number_format($data["products"][1]["UnitsOnOrder"], 0, ',', '.')}}<sup style="font-size:20px;">đ</sup>
                                                            </div>
                                                    </div>
                                                    <div class="dunitprice">
                                                            <span class="sf">Trị giá</span><br/>
                                                            <span class="ss">{{number_format($data["products"][1]["UnitPrice"], 0, ',', '.')}}<sup style="font-size:12px;">đ</sup></span>
                                                    </div>
                                            </div>
                                            <div class="df_time_view">
                                                    <div class="dtime">
                                                        <b>{{round((strtotime($data["products"][1]["EndDate"])-strtotime("now"))/(60*60*24))}}</b> ngày 
                                                        <b>{{round( ((strtotime($data["products"][1]["EndDate"])-strtotime("now"))%(60*60*24))/(60*60) )}}</b> giờ 
                                                        <b>{{round( (((strtotime($data["products"][1]["EndDate"])-strtotime("now"))%(60*60*24))%(60*60))/60 )}}</b> phút
                                                    </div>
                                                    <div class="hidden" style="position:absolute;top:0px;right :20px;padding-right:0px;line-height:40px;font-size:14px;text-align:center">
                                                             <b>{{$data["products"][1]["Sold"]+$data["products"][1]["ReorderLevel"]}}</b> người đã mua
                                                    </div>
                                            </div>
                                    </div>
                                    {{/if}}
                            </div>
                            {{for $foo=2 to count($data["products"])-1 step 3}}
                            <div class="dgroup dsmall">
                                {{for $dsi=$foo to $foo+2 step 1}}
                                    {{if isset($data["products"][$dsi]["ProductName"])}}
                                    <div class="ditem d{{$dsi-$foo}}">
                                            <div class="dphoto">
                                                    <img src="{{$data["products"][$dsi]["Image"]}}"/>
                                                    {{if $data["products"][$dsi]["Discontinued"]==1}}<div class="sold-out"></div>{{/if}}
                                                    <a href="{{base_url()}}sanpham/{{$data["products"][$dsi]["Alias"]}}">
                                                        <div class="ho50">
                                                            <div class="dship">
                                                                Giao sản phẩm
                                                            </div>
                                                            <div class="dview"></div>
                                                        </div>
                                                    </a>
                                                    <div class="ddisc">-{{$data["products"][$dsi]["Discount"]}}%</div>
                                                    
                                            </div>
                                            <div class="dtit">
                                                    <a href="{{base_url()}}sanpham/{{$data["products"][$dsi]["Alias"]}}">
                                                        <h1>
                                                            {{$data["products"][$dsi]["ProductName"]}}
                                                        </h1>
                                                    </a>
                                            </div>
                                            <div class="dprice">
                                                    <div class="dsale">
                                                            <div>
                                                                    {{number_format($data["products"][$dsi]["UnitsOnOrder"], 0, ',', '.')}}<sup style="font-size:12px;">đ</sup>
                                                            </div>
                                                    </div>
                                                    <div class="dunitprice">
                                                            <span class="sf">Trị giá</span><br/>
                                                            <span class="ss">{{number_format($data["products"][$dsi]["UnitPrice"], 0, ',', '.')}}<sup style="font-size:12px;">đ</sup></span>
                                                    </div>
                                            </div>
                                            <div class="df_time_view">
                                                <div class="dtime">
                                                        <b>{{round((strtotime($data["products"][$dsi]["EndDate"])-strtotime("now"))/(60*60*24))}}</b> ngày 
                                                        <b>{{round( ((strtotime($data["products"][$dsi]["EndDate"])-strtotime("now"))%(60*60*24))/(60*60) )}}</b> giờ 
                                                        <b>{{round( (((strtotime($data["products"][$dsi]["EndDate"])-strtotime("now"))%(60*60*24))%(60*60))/60 )}}</b> phút
                                                </div>
                                                <div class="dview-user hidden">
                                                         <b>{{$data["products"][$dsi]["Sold"]+$data["products"][$dsi]["ReorderLevel"]}}</b> người đã mua
                                                </div>
                                            </div>
                                    </div>
                                    {{/if}}
                                {{/for}}
                            </div>
                            {{/for}}
                            <span class="other">
                            
                            </span>
                                
                              <div class="clear"></div>     
                            <div style="text-align: right;height: 40px;padding-right: 20px">
                                {{for $i=0 to round($data["pages"]) step 1}}
                                <a href="{{base_url()}}san-pham/{{if $Configs["Category"]!=""}}{{$Configs["Category"]}}/{{/if}}{{$i}}" 
                                   style="border: 1px solid #ccc;background: #blue;padding: 3px 8px;text-decoration: none;
                                   margin-left: 4px;{{if $data["page"]==$i}}font-weight:bold;background: #2A92B3;color:#fff;{{/if}}">{{$i+1}}</a>
                                {{/for}}
                                
                            </div>
                            
                            <div class="clear"></div>
                    </div>
            </div>
    </div>
</div>
<script>



        
$(document).ready(function () {
    $("img.lazy").lazyload();
    var load=false;
    $(window).scroll(function(){
        if  ($(window).scrollTop() >= $(document).height() - $(window).height()-250){
            if(load){
                load=false;
                if($(".ditem").length<=62){
                var begin={{$data["begin"]}}+$(".ditem").length;
                var surl="{{base_url('deal/otherProduct')}}/"+begin+"/{{if $Configs["Category"]==""}}tat-ca{{else}}{{$Configs["Category"]}}{{/if}}/{{if $Configs["menu"]=="today"}}today{{/if}}";
                var sdata={ };
                htmlAjaxKU(surl,sdata,function(data){
                    if(data!=""){
                        $(".other").append(data);
                        $("img.lazy").lazyload();
                        load=true;   
                    }
                });
                }else{
                    var p="{{($data["begin"]/62)+1}}";
                    //location.href="{{base_url()}}san-pham/{{if $Configs["Category"]!=""}}{{$Configs["Category"]}}/{{/if}}"+p;
                }
            }
            
        }
    });            
});
        
function posY(elm) {
    var test = elm, top = 0;

    while(!!test && test.tagName.toLowerCase() !== "body") {
        top += test.offsetTop;
        test = test.offsetParent;
    }

    alert( top);
}
function posX(elm) {
    var test = elm, left = 0;

    while(!!test && test.tagName.toLowerCase() !== "body") {
        left += test.offsetLeft;
        test = test.offsetParent;
    }

    alert(left);
}

</script>